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