My script that i made is supposed to show an GUI when you step on the specific block. It works on studio but not ingame. Could someone help me ? here is the script:
script.Parent.Touched:connect(function(hit)
if hit.Name == ("Right Leg") or hit.Name == ("Left Leg") then
for i,v in pairs(game.Players:GetPlayers()) do
v.Character.Torso.CFrame = v.Character.Torso.CFrame * CFrame.new(2,2,2)
local cam = workspace.CurrentCamera
cam.CFrame = workspace.carroom.Cam.CFrame
cam.CameraType = "Scriptable"
v.PlayerGui.Upgradeshop.Enabled = true
for a,k in pairs(v:GetChildren()) do
if k:IsA("Model") then
k:Destroy()
end
end
wait(1)
if v.SelectedCar.Value == nil then
v.PlayerGui.Upgradeshop.TextLabel.Visible = true
end
local d = v.SelectedCar.Value:Clone()
d:SetPrimaryPartCFrame(game.Workspace.carroom.carspawn.CFrame * CFrame.fromEulerAnglesXYZ(0,0,1.55) * CFrame.new(-1,1,0))
d.Parent = cam
v.PlayerGui.Upgradeshop.Frame.Visible = true
wait(0.1)
while wait() do
d:SetPrimaryPartCFrame(d.Body.Base.CFrame * CFrame.fromEulerAnglesXYZ(0,.1,0))
end
end
end
end)

1 comment
Sadly, that didnt work. I tried OnServerEvent and it works an studio, but not ingame and it shows an error ingame that it only works for the server. Then i tried OnClientEvent and it didnt work for both. did i do something wrong?