Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Remote event dosent work?

Hi, I am trying to make a script that once you click on specific part it fires event, but it dosent do anything no output no errors Here is Event listener

local player = game.Players.LocalPlayer
game.ReplicatedStorage.GiveIng1.OnClientEvent:Connect(function(player)
	print("mmm")
	player.Item.Value = 1
	player.InvSpace = true
end)

Here is that thing that should fire it.

script.Parent.Parent.ClickDetector.MouseClick:Connect(function(hit)
	local name = hit.Name
	local character = workspace:WaitForChild(name)
	local player = game.Players:GetPlayerFromCharacter(character)
	
	game.ReplicatedStorage.GiveIng1:FireClient(player)
	print("clicked")
end)

I hope you can help me.

10 comments

0

I'm sorry, what are you trying to do? You need to specific on what you are trying to do. Just saying 'Remote event doesn't work' isn't descriptive enough.

0

Can't you just get the character from hit.Parent?

0

@CrypxticDoge hit is basically the character. You don't need hit.Parent.

0

I want my remote event fire once i click on part but once i click the first script i guess works fine i am not sure but the event listener dosent print anything what its suposed to do.

0

Try using breakpoints to debug

0

I'm saying what you are trying to accomplish. What is your goal? Are you trying to change values in a client? If so, that is not a good idea.

0

There is no need for the variables name and character, you can just use GetPlayerFromCharacter(Hit)

0

@kistupas12344 Why do you need to use a RemoteEvent? You can just change it in the server script.

0

So how do i change insde player values?

0

Remove the player parameter from the OnClientInvoke script.

1 answer

Hey there, in your first script you used the player parameter on a OnClientEvent script. This will likely cause it to error. Another factor to this not working is using a local script to change the values. You must use a server script or regular script to change the values. I recommend not using remote events for this situation and simply using the second script. Change the code to this: script.Parent.Parent.ClickDetector.MouseClick:Connect(function(hit) local character = workspace:WaitForChild(hit.Name) local player = game.Players:GetPlayerFromCharacter(character) player.Item.Value = 1 player.InvSpace = true print("clicked") end) I may be incorrect of some things on the script I provided but I hope this helps. Duckie.

1 comment

0

Apologies of the cramped code, I may have typed it in a way that made it do this.

This discussion is preserved as it was. New answers, comments, and votes are closed.