Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:41 PM |
For like literally no reason, this script isn't working. I've tried waits, moving it, everything I can think of.
local ReplicatedStorage = game:GetService("ReplicatedStorage") local p = game.Players.LocalPlayer local Jis = p:WaitForChild("leaderstats").Jis
ReplicatedStorage.ChildAdded:connect(function(Child) wait() if(Child:IsA("RemoteEvent"))then Child.OnClientEvent:connect(function() Jis.Value = Jis.Value +math.random(5, 20) end) end end)
It only detects the RemoteEvent one time, after that, it never detects it again. Here is what adds the event:
local Points = Instance.new("RemoteEvent") Points.Parent = game.ReplicatedStorage wait(1) Points:Destroy()
That is part of a larger script, but the rest is kind of irrelevant. And YES, IT DOES GET CREATED MORE THAN ONCE! Anyway, why is it not working? |
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:43 PM |
1. why are you creating your remotes with scripts? 2. you're not even firing the remote that you create
u should add filtering - devious |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:46 PM |
1. What? How else am I going to do it? 2. Firing? |
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:47 PM |
._______________________________.
right click replicated storage new object remoteevent
u should add filtering - devious |
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:48 PM |
*insert object
u should add filtering - devious |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:48 PM |
| No, I have to add it via a script. |
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:50 PM |
why?
u should add filtering - devious |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:52 PM |
| Because it is only supposed to fire when my part touches something. I'm 99% sure that part has nothing to do with this problem. |
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:53 PM |
you don't seem to understand how remotes work
put a remotevent in replicatedstorage
part.Touched:connect(function() game.ReplicatedStorage.RemoteEvent:FireClient() end)
u should add filtering - devious |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:55 PM |
Anyway, that's not what I meant at all, I didn't ask when somone touches the part, I said when you touch the part. Here's my whole script:
----------------- --| Constants |-- ----------------- local players = game:GetService("Players") local BLAST_RADIUS = 10 local BLAST_PRESSURE = 4500
-- Rocket will fly through things named these local ROCKET_IGNORE_LIST = {rocket = 1, handle = 1, effect = 1, water = 1} --NOTE: Keys must be lowercase, values must evaluate to true
-------------------- --| WaitForChild |-- --------------------
-- Waits for parent.child to exist, then returns it local function WaitForChild(parent, childName) assert(parent, "ERROR: WaitForChild: parent is nil") while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end return parent[childName] end
----------------- --| Variables |-- -----------------
local DebrisService = Game:GetService('Debris')
local Rocket = script.Parent local CreatorTag = WaitForChild(Rocket, 'creator')
local Connection = nil
----------------- --| Functions |-- -----------------
-- Returns the ancestor that contains a Humanoid, if it exists local function FindCharacterAncestor(subject) if subject and subject ~= Workspace then local humanoid = subject:FindFirstChild('Humanoid') if humanoid then -----------------------------------------------------Add points local Points = Instance.new("RemoteEvent") Points.Parent = game.ReplicatedStorage wait(1) Points:Destroy() -----------------------------------------------------Done adding points. return subject, humanoid else return FindCharacterAncestor(subject.Parent) end end return nil end
local function OnExplosionHit(hitPart) if hitPart then local _, humanoid = FindCharacterAncestor(hitPart.Parent) if humanoid and humanoid.Health > 0 then local hitBindable = humanoid:FindFirstChild('Hit') if hitBindable then hitBindable:Invoke(0, CreatorTag) else print("Could not find BindableFunction 'Hit'") end end end end
local function OnTouched(otherPart) if Rocket and otherPart then -- Fly through anything in the ignore list if ROCKET_IGNORE_LIST[string.lower(otherPart.Name)] then return end
-- Fly through the creator local myPlayer = CreatorTag.Value if myPlayer and myPlayer.Character and myPlayer.Character:IsAncestorOf(otherPart) then return end
-- Create the explosion local explosion = Instance.new('Explosion') explosion.BlastPressure = BLAST_PRESSURE explosion.BlastRadius = BLAST_RADIUS explosion.Position = Rocket.Position explosion.Hit:connect(OnExplosionHit) explosion.Parent = Workspace --Add some light local Light = Instance.new("PointLight") Light.Color = Color3.new(255, 85, 0) Light.Range = 30 Light.Parent = Rocket -- Start playing the boom sound local boomSound = Rocket:FindFirstChild('Boom') if boomSound then boomSound:Play() end
-- NOTE: -- If we just destroyed the rocket at this point, the boom sound would be destroyed too, -- so instead we will hide the rocket, keep it in the same spot, and schedule it for deletion
-- Stop playing the swoosh sound local swooshSound = Rocket:FindFirstChild('Swoosh') if swooshSound then swooshSound:Stop() end
-- Put out the fire local fire = Rocket:FindFirstChild('Fire') if fire then fire:Destroy() end
Rocket.Transparency = 1 Rocket.CanCollide = false Rocket.Anchored = true DebrisService:AddItem(Rocket, 3) --Remove the light wait (.2) Light: Destroy()
-- Destroy the connection so this method won't be called again Connection:disconnect() end end
-------------------- --| Script Logic |-- --------------------
-- Arm the rocket and save the touch connection so we can disconnect it later Connection = Rocket.Touched:connect(OnTouched)
|
|
|
| Report Abuse |
|
|
|
| 24 May 2015 04:56 PM |
um
no
u should add filtering - devious |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 24 May 2015 04:59 PM |
| Ugh, I tried adding Child:FireClient() but that added an error. And I'm adding the event that way, period. |
|
|
| Report Abuse |
|
|