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

Why is this not returning the right name/ tool?

Basically making a sword fighting system and for some odd reason when I fire the event it returns the actual player and the players name.

-- LOCAL
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
	if player.Character.ExtraData.Armed.Value == true then
local WeaponName1 = script.Weap.Value 
local WeaponName = WeaponName1
print(WeaponName)
print("Is armed L")
if player.Character:FindFirstChild(WeaponName) then
	print("Found Weapon L")
local Weapon = player.Character:FindFirstChild(WeaponName)
	game.ReplicatedStorage.Combat.Slash:FireServer(player, Weapon)
end
end
end)
-- SERVER
local thing1 = game.ReplicatedStorage.Combat.Slash
thing1.OnServerEvent:connect(function(player, Weapon)
	print("Slash Fired S")
	print(Weapon.Name)

That is the only part of the serverscript it does, yes the actual script has ends and all that. But you see when it prints the sword name for the local it prints ("Starter") (The sword name) but when it prints for the server it prints my username. I have also tried to just send the name of the item instead of the item itself to the server and it still won't work at all and just sends my username on the server.

1 answer

✓ Accepted answer

You don't need to send the player through the localscripts arguments try only sending the weapon tell me if it works or not

-- LOCAL
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
    if player.Character.ExtraData.Armed.Value == true then
local WeaponName1 = script.Weap.Value 
local WeaponName = WeaponName1
print(WeaponName)
print("Is armed L")
if player.Character:FindFirstChild(WeaponName) then
    print("Found Weapon L")
local Weapon = player.Character:FindFirstChild(WeaponName)
    game.ReplicatedStorage.Combat.Slash:FireServer(Weapon)
end
end
end)

14 comments

0

How would the server script know what the "player" is then?

0

The server script knows the player by default when using a remote event theirs no need to define it

0

for me its erroring.

0

What does it say?

0

its just underlining lots of variables. (Red underline

0

did u get rid of it from the server script too?

0

also it needs the player so it can make them use a animation and make sure they are already not attacking

0

Yes I did change it on the server too

0

thing1.OnServerEvent:connect(function(player, Weapon) keep this the same just remove it from game.ReplicatedStorage.Combat.Slash:FireServer(Weapon)

0

don't remove player from the server

0

Just did what you said its work except no animation and no damage. but all the prints except for one in the middle work.

0

nvm fixed animation

0

Alright so it worked?

0

I'm still making sure it works 100% before accepting the ans

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