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

How do i make a IF PART CLICKED RUN A LOCAL SCRIPT?

Asked by 2 years ago
Edited 2 years ago

soooo i am making a roblox horror game and i have made a script.

the script is suposed to run a local script after being clicked...

but the local script wont run after watching many tutorials on youtube.

please help me.

i really want to finish my game

ALL CODE USED:

USES REMOTE EVENTS

if clicked normal script{

local RS = game:GetService("ReplicatedStorage")
local ButtonClicked = RS:WaitForChild("PlayButtonShow")

function Clicked(Player)
    local button = script.Parent.PlayButton:Clone()
    button.Parent = Player.PlayerGui
    ButtonClicked:FireClient()
end

script.Parent.ClickDetector.MouseClick:Connect(Clicked)

}

local script{

local RS = game:GetService("ReplicatedStorage")
local ButtonClicked = RS:WaitForChild("PlayButtonShow")

function Run()
    game.StarterPlayer.CameraMaxZoomDistance = 10
    game.StarterPlayer.CameraMinZoomDistance = 10
end

ButtonClicked.OnClientFunction:Connect(Run)

}

0
Is this a RemoteEvent or a RemoteFunction? Where is the local script located? NotThatFamouss 605 — 2y
0
the local script is in a file i made and i uses a remote event and put it in replicated storage ohhophophoplikebunny 25 — 2y

2 answers

Log in to vote
0
Answered by
epoke466 100
2 years ago

The problem is that you are changing the StarterPlayer CameraMaxZoomDistance and CameraMinZoomDistance.

You need to change the LocalPlayers CameraMaxZoomDistance and CameraMidZoomDistance.

Otherwise, you will not notice a change.

0
i tried that ohhophophoplikebunny 25 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

A few problems here

local RS = game:GetService("ReplicatedStorage")
local ButtonClicked = RS:WaitForChild("PlayButtonShow")

function Clicked(Player)
    local button = script.Parent.PlayButton:Clone()
    button.Parent = Player.PlayerGui
    ButtonClicked:FireClient(Player) -- You weren't being specific on what client you want to fire. 
end

script.Parent.ClickDetector.MouseClick:Connect(Clicked)

Local script:

local RS = game:GetService("ReplicatedStorage")
local ButtonClicked = RS:WaitForChild("PlayButtonShow")
local player = game.Players.LocalPlayer -- Get the localplayer

function Run()
    player.CameraMaxZoomDistance = 10 -- Replace StarterPlayer with the player
    player.CameraMinZoomDistance = 10
end

ButtonClicked.OnClientEvent:Connect(Run) -- I am sure it is suppose to be OnClientEvent...
0
it didnt work :( ohhophophoplikebunny 25 — 2y
0
do i put the RemoteEvent in replicated storage ohhophophoplikebunny 25 — 2y
0
oFc, i thought you already put it?? AProgrammR 398 — 2y
0
i did out it ohhophophoplikebunny 25 — 2y

Answer this question