generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: remote events

Previous Thread :: Next Thread 
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
20 Jul 2016 06:22 PM
i have this script and local script thats supposed to increase a value(which is the games currency) when the brick is touched
the first time it works fine, but the second time the value doesnt increase a bit
the output is clean
how come its doing this?

the server script:
function onTouch(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local event = Instance.new("RemoteEvent")
event.Parent = game:GetService("Lighting")
event.Name = "CoinEvent"
event:FireClient(game:GetService("Lighting"))
print("Event fired")
wait(0.1)
script.Parent:Destroy()
end
end

script.Parent.Touched:connect(onTouch)

the localscript:

game.Lighting:WaitForChild("CoinEvent").OnClientEvent:connect(function()
print("Ok")
local plr = game:GetService("Players").LocalPlayer
local Reward = math.random(6, 9)
plr.PlayerGui.Stats.Holder.Money.Value.Value = plr.PlayerGui.Stats.Holder.Money.Value.Value + Reward
end)
Report Abuse
kools is not online. kools
Joined: 11 Jan 2009
Total Posts: 1659
20 Jul 2016 06:49 PM
You destroy the parent of the script so the script is destroyed and won't run anymore.

Unless there are multiple things with this script in them? Also be sure to not use Lighting anymore for storing things to be replicated. I suggest using ReplicatedStorage.
Report Abuse
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
20 Jul 2016 06:53 PM
@kools

what if you set the parent of the script to nil?

can you destroy the parent of nil?
Report Abuse
secret6timb1 is not online. secret6timb1
Joined: 11 Sep 2013
Total Posts: 1817
20 Jul 2016 06:54 PM
can you destroy nil***

o3o
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
20 Jul 2016 07:16 PM
why should i use replicatedstorage?

is it like more efficent?
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
20 Jul 2016 07:23 PM
i changed script.Parent:Destroy() into event:Destroy() so it destroys the event instead, but still doesnt work
it prints the Event fired and the ok the first time, but the second time i only see the event fired.

w0t
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
20 Jul 2016 07:25 PM
i made a couple tweaks to my server script, but still no signs of success:

function onTouch(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local event = Instance.new("RemoteEvent")
event.Parent = game:GetService("Lighting")
event.Name = "CoinEvent"
event:FireClient(game:GetService("Lighting"))
print("Event fired")
event:Destroy()
script.Disabled = true
end
end

script.Parent.Touched:connect(onTouch)
Report Abuse
Alimegacorn is not online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
21 Jul 2016 07:51 PM
bumper cars
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image