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)

6 comments

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

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

0

I did a remotevent. But when i step on the pad, nothng happens.

0

All i get is Players.ieatandisbaconhair.PlayerGui.LocalScript:4: attempt to index local 'player' (a nil value)

0

Where is the alleged RemoteEvent?

0

replicatedsstorage