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

Script that shows GUI when stepped on a part works in studio but not in the roblox game?

Asked by 6 years ago

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 answer

Log in to vote
0
Answered by 6 years ago

Is your script FE? If not, then set it to be, you won't regret it, trust me. You should put the part of the script that makes the gui appear in a local script inside the player and tie it with the script which detects the touch using a remoteevent (if you want the gui to appear on all players, just do :FireAllClients (or something like that))

If you don't understand, you should probably look up remote events.

0
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? ieatandisbaconhair 77 — 6y
Ad

Answer this question