Where should I put the local script?

I have a script lying in the ServerScriptService that should trigger a remote event when a player spawns, but remote events can only trigger a Local Script, where should I put the Local Script to make everything work?

game.Players.PlayerAdded:Connect(function(player)
	print(player.Name.." joined")
	player.CharacterAdded:Connect(function(character)
		print(player.Name.." spawned")

		if player.korzina.Classic.Value == 2 then
			game.ReplicatedStorage.SkinClassic:FireServer("rbxasset://textures/SwordTexture.png")
		end
		if player.korzina.Gold.Value == 2 then
			game.ReplicatedStorage.SkinGold:FireServer("rbxassetid://129239835607605")
		end
		if player.korzina.Death.Value == 2 then
			game.ReplicatedStorage.SkinDeath:FireServer("rbxassetid://75220483140792")
		end

	end)
end)

6 Likes

Also, if I transfer the contents of the script to the local script, then nothing will work.

1 Like

instead of FireServer use FireClient or FireAllClients

1 Like

Anywhere on the client, you can put it in:

  • StarterGUI

  • StarterPlayerScripts

  • StarterCharacterScripts

I would go for StarterPlayerScripts though.

And use FireClient and FireAllClients for the server
and FireServer for the client.

2 Likes

If you need any more information, there are tons of youtube videos and the roblox documentation for remote events

1 Like

is it in the local script? or can the script be left as usual?

If it’s a server script, use FireClient and FireAllClients, to send information to the client.

If its a local script, use FireServer to send information to the server.

From the script you provided, it looks like a server script, so FireClient and FireAllClients should be used.

If you want to send information from server to server or client to client, a bindable event should be used.

1 Like

I need the event to activate the script in the ServerScriptService. is there any way to rewrite this script in local so that it works?

Im too lazy to rewrite everything for you, though if you want to send information between 2 server scripts, use a bindable event. Which I think your trying to do here.

I think for anyone to be able to help you, you will need to explain what is happening on the other script that is being triggered by this remote. It may be that you don’t even need a remote.

What does the other script look like?

I’m working with Bindable events right now, my scripts look like this:
the script that is above:

game.Players.PlayerAdded:Connect(function(player)
	print(player.Name.." joined")
	player.CharacterAdded:Connect(function(character)
		print(player.Name.." spawned")
		wait(5)

		if player.korzina.Classic.Value == 2 then
			game.ReplicatedStorage.BEClassic:Fire("rbxasset://textures/SwordTexture.png")
			print(player.Name.." C skin == 2")
		end
		if player.korzina.Gold.Value == 2 then
			game.ReplicatedStorage.BEGold:Fire("rbxassetid://129239835607605")
			print(player.Name.." G skin == 2")
		end
		if player.korzina.Death.Value == 2 then
			game.ReplicatedStorage.BEDeath:Fire("rbxassetid://75220483140792")
			print(player.Name.." D skin == 2")
		end
	end)
end)

and here’s the script you asked for:

game.ReplicatedStorage.SkinGold.OnServerEvent:Connect(function(player, skinID)
	local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
	if player.leaderstats.Coins.Value >= 250 and player.korzina.Gold.Value == 0 then
		sword.Handle.Mesh.TextureId = skinID
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 250
		player.korzina.Gold.Value = 1
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Purchared"
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold:FindFirstChild("ImageLabel"):Destroy()
	end
	if player.korzina.Gold.Value == 1 then
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Equipped"
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold:FindFirstChild("ImageLabel"):Destroy()
		sword.Handle.Mesh.TextureId = skinID
		player.korzina.Gold.Value = 2

		if player.korzina.Death.Value == 2 then
			player.korzina.Death.Value = 1
		end
		if player.korzina.Classic.Value == 2 then
			player.korzina.Classic.Value = 1
		end
	end

end)
game.ReplicatedStorage.BEGold.Event:Connect(function(player, skinID)
	local sword = player.Backpack:FindFirstChild("Sword")
	sword.Handle.Mesh.TextureId = skinID
	print("Skin downloaded")
end)

I could be wrong but I don’t think ‘player’ will be passed with a bindableEvent. Why can’t this be done in one server script?

1 Like

Couple problems here, first off, you’re not passing the player variable through despite calling it in the .Event connection.

Second off, your player.korzina.gold.value, either korzina is a username or its your stat folder, if its a username, it should be removed, if its a stat folder, I’m not sure why you have nothing checking for gold.Value == 2

Thanks, for some reason I didn’t think of it before. Now my script looks like this and everything is working:)

game.ReplicatedStorage.SkinClassic.OnServerEvent:Connect(function(player)
	local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
	if player.leaderstats.Coins.Value >= 100 and player.korzina.Classic.Value == 0 then
		sword.Handle.Mesh.TextureId = "rbxasset://textures/SwordTexture.png"
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 100
		player.korzina.Classic.Value = 1
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic.TextLabel.Text = "Purchared"
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic:FindFirstChild("ImageLabel"):Destroy()
	end
	if player.korzina.Classic.Value == 1 then
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic.TextLabel.Text = "Equipped"
		sword.Handle.Mesh.TextureId = "rbxasset://textures/SwordTexture.png"
		player.korzina.Classic.Value = 2

		if player.korzina.Gold.Value == 2 then
			player.korzina.Gold.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold:FindFirstChild("ImageLabel"):Destroy()
		end
		if player.korzina.Death.Value == 2 then
			player.korzina.Death.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death:FindFirstChild("ImageLabel"):Destroy()
		end
	end
	
end)
------------------
game.ReplicatedStorage.SkinGold.OnServerEvent:Connect(function(player)
	local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
	if player.leaderstats.Coins.Value >= 250 and player.korzina.Gold.Value == 0 then
		sword.Handle.Mesh.TextureId = "rbxassetid://129239835607605"
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 250
		player.korzina.Gold.Value = 1
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Purchared"
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold:FindFirstChild("ImageLabel"):Destroy()
	end
	if player.korzina.Gold.Value == 1 then
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Equipped"
		sword.Handle.Mesh.TextureId = "rbxassetid://129239835607605"
		player.korzina.Gold.Value = 2

		if player.korzina.Death.Value == 2 then
			player.korzina.Death.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death:FindFirstChild("ImageLabel"):Destroy()
		end
		if player.korzina.Classic.Value == 2 then
			player.korzina.Classic.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic:FindFirstChild("ImageLabel"):Destroy()
		end
	end

end)
----------------
game.ReplicatedStorage.SkinDeath.OnServerEvent:Connect(function(player)
	local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
	if player.leaderstats.Coins.Value >= 350 and player.korzina.Death.Value == 0 then
		sword.Handle.Mesh.TextureId = "rbxassetid://75220483140792"
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - 350
		player.korzina.Death.Value = 1
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death.TextLabel.Text = "Purchared"
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death:FindFirstChild("ImageLabel"):Destroy()
	end
	if player.korzina.Death.Value == 1 then
		player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Death.TextLabel.Text = "Equipped"
		sword.Handle.Mesh.TextureId = "rbxassetid://75220483140792"
		player.korzina.Death.Value = 2

		if player.korzina.Gold.Value == 2 then
			player.korzina.Gold.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Gold:FindFirstChild("ImageLabel"):Destroy()
		end
		if player.korzina.Classic.Value == 2 then
			player.korzina.Classic.Value = 1
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic.TextLabel.Text = "Purchared"
			player.PlayerGui.ScreenGui.Frame.Skins.Frame.Frame.Classic:FindFirstChild("ImageLabel"):Destroy()
		end
	end
end)

---gold "rbxassetid://129239835607605"
---death "rbxassetid://75220483140792"
---classic "rbxasset://textures/SwordTexture.png"

game.Players.PlayerAdded:Connect(function(player)
	print(player.Name.." joined")
	player.CharacterAdded:Connect(function(character)
		print(player.Name.." spawned")
		wait(6)

		if player.korzina.Classic.Value == 2 then
			local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
			sword.Handle.Mesh.TextureId = "rbxasset://textures/SwordTexture.png"
			print(player.Name.." C skin == 2")
		end
		if player.korzina.Gold.Value == 2 then
			local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
			sword.Handle.Mesh.TextureId = "rbxassetid://129239835607605"
			print(player.Name.." G skin == 2")
		end
		if player.korzina.Death.Value == 2 then
			local sword = player.Backpack:FindFirstChild("Sword") or player.Character:FindFirstChild("Sword")
			sword.Handle.Mesh.TextureId = "rbxassetid://75220483140792"
			print(player.Name.." D skin == 2")
		end
	end)
end)
2 Likes