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 Event only firing once?

Previous Thread :: Next Thread 
Morficc is not online. Morficc
Joined: 19 Dec 2016
Total Posts: 22
05 Mar 2017 04:56 PM
Goal:

When users click on an item, data on this item is collected through a modulescript, then a remote event is kicked off, sending the data obtained through an argument of the FireClient. Then, in the local script that picks up the remote event, a GUI is opened with the information needed populating into the GUI window.

This all works well so far, except it only works once. After the first GUI is closed, clicking on an item again does recognize the click, and obtains the information, but the remote event is not called again. Anyone know why?

Server Script:

local ResourceManager = require(game.ReplicatedStorage.ResourceManager)

for _,v in next,game.Workspace.Items:GetChildren()do
v.ClickDetector.MouseClick:connect(function(player)
local objectType = v.ObjectType.Value
local data = ResourceManager.Resources[objectType]

local event = Instance.new("RemoteEvent")
event.Name = "ItemClick"
event.Parent = player
print('Click Event Created')
event:FireClient(player, data)
end)
end



Localscript:

game.Players.LocalPlayer:WaitForChild("ItemClick").OnClientEvent:connect(function(arguments)
print('Remote Event Connected')
local ResourceManager = require(game.ReplicatedStorage.ResourceManager)
local gui = game.Players.LocalPlayer.PlayerGui.PickupItemGui.ImageLabel
local data = arguments
print(arguments)
gui.TextLabel.Text = data.Name
if gui.Visible == false then
gui.Visible = true
gui.ResourceType.Value = data.ID
else
end
end)
Report Abuse
Morficc is not online. Morficc
Joined: 19 Dec 2016
Total Posts: 22
05 Mar 2017 05:33 PM
Sorry in advance, if that didn't make much sense.

A little further information:

When you first click on an item, it prints:

Click Event Created
Remote Event Connected.

the next time you click on something though, it only prints:

Click Event Created.

It is not making it over to the localscript.
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
05 Mar 2017 05:43 PM
store the remove event in replicated storage


Report Abuse
Tefmon is not online. Tefmon
Joined: 22 Jun 2015
Total Posts: 90624
05 Mar 2017 05:44 PM
d


Report Abuse
Morficc is not online. Morficc
Joined: 19 Dec 2016
Total Posts: 22
05 Mar 2017 05:49 PM
Just want to clarify. Store the remote event in replicatedstorage? So set the parent of ItemClick to Replicatedstorage?
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
05 Mar 2017 05:49 PM
Have the remote already made in rs

https://forum.roblox.com/Forum/ShowPost.aspx?PostID=200061209


Report Abuse
Morficc is not online. Morficc
Joined: 19 Dec 2016
Total Posts: 22
05 Mar 2017 05:56 PM
Ok. I tried that. Still only works once. The second item click registers the click and sets values, but my localscript never picks up the eventfire


local ResourceManager = require(game.ReplicatedStorage.ResourceManager)

for _,v in next,game.Workspace.Items:GetChildren()do
v.ClickDetector.MouseClick:connect(function(player)
local objectType = v.ObjectType.Value
local data = ResourceManager.Resources[objectType]

game.ReplicatedStorage.ItemClick:Clone()
game.ReplicatedStorage.ItemClick:Clone().Parent = player
print('Click Event Created')
player.ItemClick:FireClient(player, data)
end)
end
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
05 Mar 2017 06:03 PM
--server

local ResourceManager = require(game.ReplicatedStorage.ResourceManager)
local event = game.ReplicatedStorage:WaitForChild('RemoteEvent')
local items = workspace.Items

for i,v in next, items:GetChildren() do
v.ClickDetector.MouseClick:connect(function(player)
local objectType = v.ObjectType.Value
local data = ResourceManager.Resources[objectType]
event:FireClient(player,data)
end)
end

--local

local ResourceManager = require(game.ReplicatedStorage.ResourceManager)
local event = game.ReplicatedStorage:WaitForChild('RemoteEvent')
local player = game.Players.LocalPlayer
local itemgui = player.PlayerGui:WaitForChild('PickupItemGui')
local image = itemgui:WaitForChild('ImageLabel')
local label = image:WaitForChild('TextLabel')
local rtype = image:WaitForChid('ResourceType')

event.OnClientEvent:connect(function(data) --this should be a table
label.Text = data.Name -- why are you trying to send an object?
if not image.Visible then
image.Visible = true
rtype.Value = data.ID
end
end)


Report Abuse
Morficc is not online. Morficc
Joined: 19 Dec 2016
Total Posts: 22
05 Mar 2017 08:27 PM
Thank you TimeTicks. That did work :)
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