Having Problem with adding the players UserId in the IntValue!

I’m having a problem with adding the player UserId in the IntValue

When the model is cloned into the workspace I want to add the players Id in the IntValue so it the button can delete the player’s Wagon only not anyone else’s wagon

The Script is in a regular script

local ServerStorage = game:GetService("ServerStorage")
local wagon = ServerStorage.Wagons.HermesWagonInHB1
local deb = script.Parent.Parent.Parent.Parent.deb

script.Parent.MouseButton1Click:Connect(function()
    if deb.Value == false then
        wait(.2)
        wagon:Clone().Parent = game.Workspace
        wagon:Clone().User.Value = script.Parent.Parent.Parent.Parent.Parent.Parent.UserId

        deb.Value = true
    elseif deb.Value == true then
        wait(.2)
        game.Workspace:FindFirstChild("HermesWagonInHB1"):Destroy()
        deb.Value = false
     end
end)

First:
Could you show us the error
Second:
This should be a LocalScript as you’re requiring the LocalPlayer, in the wrong way

There’s no error but when I check the Value the player UserId isn’t in the Value

``Okay, can you move this to a LocalScript and change Variables up a bit?

I tried that now there’s a error

local wagon = game.ServerStorage.Wagons.HermesWagonInHB1
local deb = script.Parent.Parent.Parent.Parent.deb
local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function()
    if deb.Value == false then
        wait(.2)       
        wagon:Clone().User.Value = player.UserId
        wagon:Clone().Parent = game.Workspace
 
        deb.Value = true
    elseif deb.Value == true then
        wait(.2)
        game.Workspace:FindFirstChild("HermesWagonInHB1"):Destroy()
        deb.Value = false
    end
end)
  22:32:48.194  Wagons is not a valid member of ServerStorage "ServerStorage"  -  Client - LocalScript:2

You can’t acces ServerStorage from there, move it to ReplicatedStorage

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.