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

Why does my Remote Event not receive a numerical value?

Asked by 4 years ago

I am working on a script that heals the player if he has enough points, when I call the remote event it only sends my user name twice instead of the price. Here is my script:

if Action.Name == "Medkit" then
                    local Player = game.Players.LocalPlayer
                    local character = Player.Character or Player.CharacterAdded:Wait()
                    local humanoid = character:WaitForChild("Humanoid")
                    local health = humanoid.Health
                    local maxHealth = humanoid.MaxHealth
                    local price = (maxHealth-health)*5
                    if Mag <= Action.Range.Value and cash.Value >= price and health > 0 then
                        Action.Event:FireServer(Player,price) 
                        break

When I say print(Player), print(price) the output shows Channy97, Channy97

Any ideas on how to fix this? Thank you.

1 answer

Log in to vote
1
Answered by 4 years ago

I figured it out. When firing a remote event the player is automatically sent as a parameter. So Action.Event:FireServer(price) needs to be sent instead of Action.Event:FireServer(Player,price)

i.e: Remove "Player"

Ad

Answer this question