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.
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.