Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Remote event dosent work?

Asked by 3 years ago

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.

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. Dovydas1118 1495 — 3y
0
Can't you just get the character from hit.Parent? CrypxticDoge 135 — 3y
0
@CrypxticDoge hit is basically the character. You don't need hit.Parent. Dovydas1118 1495 — 3y
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. kristupas12344 26 — 3y
View all comments (6 more)
0
Try using breakpoints to debug CrypxticDoge 135 — 3y
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. Dovydas1118 1495 — 3y
0
There is no need for the variables name and character, you can just use GetPlayerFromCharacter(Hit) CrypxticDoge 135 — 3y
0
@kistupas12344 Why do you need to use a RemoteEvent? You can just change it in the server script. CrypxticDoge 135 — 3y
0
So how do i change insde player values? kristupas12344 26 — 3y
0
Remove the player parameter from the OnClientInvoke script. JudgeDuckie 25 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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.

0
Apologies of the cramped code, I may have typed it in a way that made it do this. JudgeDuckie 25 — 3y
Ad

Answer this question