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

Why does this script when a part has been touched only work in studio, but not ingame?

Asked by 5 years ago

I made a pad, that if you touch it, a gui pops up. But it only works in studio , but not ingame. Please help!

script:

local rp = game.ReplicatedStorage
local ev = rp.EnterPaintShop
local cam = game.Workspace.CurrentCamera
local debounce = false

function something(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        for i,v in pairs(plr.Character:GetChildren())do
    if v:IsA("Model") and v.Name == plr.Name.."'s Car" then
    v:Destroy()
    end
    for _,k in pairs(cam:GetChildren())do
    k:Destroy()
    end
    if not debounce then
    debounce = true
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
    local c = plr:WaitForChild("SelectedCar").Value:Clone()
    c.Parent = game.Workspace.CurrentCamera
    c:SetPrimaryPartCFrame(game.Workspace.painttp.CFrame)
    plr.Character.Torso.CFrame = plr.Character.Torso.CFrame + Vector3.new(3,0,3)
    plr.Character.Humanoid.WalkSpeed = 0
    plr.PlayerGui.PaintGUI.Enabled = true
    cam.CameraSubject = game.Workspace.painttp
    debounce = false
        end
        end
    else
        return nil
    end
end

script.Parent.Touched:Connect(something)
0
Because of line 24. You can't modify the PlayerGui's descendants from the server unless the server placed it there. So you'll need a remote User#19524 175 — 5y
0
There is something called RemoteEvents, learn how to communicate through Server to client, Here is the link: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events#Server_to_Client mixgingengerina10 223 — 5y
0
I did a remotevent. But when i step on the pad, nothng happens. ieatandisbaconhair 77 — 5y
0
All i get is Players.ieatandisbaconhair.PlayerGui.LocalScript:4: attempt to index local 'player' (a nil value) ieatandisbaconhair 77 — 5y
View all comments (2 more)
0
Where is the alleged RemoteEvent? ABK2017 406 — 5y
0
replicatedsstorage ieatandisbaconhair 77 — 5y

Answer this question