#Client sided objects

105 messages · Page 1 of 1 (latest)

split tulip
#

I have absolutly no idea on how to make client sided objects and i kinda need help with it

trim mesa
#

Create an object on a local script

split tulip
#

so i make a empty local script and put the part in?

#

or do i add a script for it

#

like this?

#

local player = game.Players.LocalPlayer -- Get the local player
local character = player.Character or player.CharacterAdded:Wait() -- Get the player's character

-- Create a new part locally
local part = Instance.new("Part")
part.Size = Vector3.new(4, 1, 2)
part.Position = character.HumanoidRootPart.Position + Vector3.new(5, 0, 0) -- Place it near the player
part.Anchored = true -- Prevent it from falling
part.Parent = game.Workspace -- Parent it to the Workspace, but only the local player will see it

snow hemlock
split tulip
#

so i put the local script inside the part?

snow hemlock
#

no you put this into starterplayerscripts

split tulip
#

So i make a local script in starterplayerscripts and add this?

snow hemlock
split tulip
#

i see that it spawns a part next to the player

#

but how do i make it like that for already existing parts

snow hemlock
#

you cant really do that

split tulip
#

dang

#

so how do i change the rotations and stuff

coarse furnaceBOT
#

studio** You are now Level 8! **studio

snow hemlock
#

I guess its possible to move it to replicated storage and just parent it to workspace in a localscript

split tulip
#

cause i made a part like this that explodes when you touch it

#

but it has to be local

snow hemlock
#

i mean just make the explosion client sided no?

split tulip
#

the plate must explode and go away

#

for the client side

snow hemlock
#

then just do part:destroy() on the client?

split tulip
#

idk how

cerulean steeple
#

it's not going to let the player move

#

unanchor it

#

remove collision

split tulip
#

i know

cerulean steeple
#

and add a weld constraint

#

that should fix

cerulean steeple
split tulip
#

how do i make the explosion client sided?

cerulean steeple
#

you want to make it using the explosion instance?

split tulip
#

i have everything i want to make a part that already exists a local part

#

but also the explosion

snow hemlock
#
local part =game.ReplicatedStorage.Part
part.Parent = game.Workspace

local function explode()
    --script
    
    part:Destroy()
end

part.Touched:Connect(explode)
split tulip
#
local explosion_Radius = 5

local function createExplosion()
    local explosion = Instance.new("Explosion")
    explosion.Position = part.Position
    explosion.BlastRadius = explosion_Radius
    explosion.Parent = part
end

local function onTouch(hit)
    -- Check if the touched part belongs to a player
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        -- If it is a player, kick them
        player:Kick("You will suffer the consequences")
    end
end

part.Touched:Connect(function(hit)
    -- Create the explosion
    createExplosion()

    -- Handle the player kick logic
    onTouch(hit)
end) ```
#

here is the code

cerulean steeple
#

ok

cerulean steeple
split tulip
#

its working

#

i just want it to be client sided

cerulean steeple
#

well the script is not a local script?

coarse furnaceBOT
#

studio** You are now Level 2! **studio

cerulean steeple
#

nobody loves u

#

nft ahh scam

#

anyways back to the topic

split tulip
#

so i just change it to a local script and its client sided?

snow hemlock
cerulean steeple
#

localscript u mean

split tulip
#

yea

cerulean steeple
#

put the same code in a localscript then?

split tulip
#

now it doenst work

cerulean steeple
#

do you get a error in the output?

split tulip
#

no

cerulean steeple
#

is your script.Parent (part) in the workspace?

split tulip
#

yea

cerulean steeple
#

localscripts are not permitted to run in the workspace

#

put it in starterplayerscripts

#

then

#

replace part = script.Parent with part = workspace.whateveryourpartnameis

#

now is it working?

split tulip
#

im checking

snow hemlock
#
local part = game.Workspace:WaitForChild("Part")
cerulean steeple
#

mhm/

#

now?

split tulip
#

Nope

cerulean steeple
#

hold on ill fix u r script

#

opening it in roblox studio

#

..

#

kicking a player from localscript?

#

why do u want it to be local when you're kicking players

#

i didnt even see that

#

also it should give you a erorr now

split tulip
#

cause the explosion ruins some of the other stuff

cerulean steeple
#

alright

#

look

#

ill fix up ur script

#

alr

cerulean steeple
#

ahem ahem

#

put this in your localscript

#
local radius = 5

local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("ConsequenceRemote")

part.Touched:Connect(function(basepart)
    if basepart.Parent:IsA("Model") and basepart.Parent:FindFirstChild("HumanoidRootPart") and basepart.Parent == game.Players.LocalPlayer.Character then
        remote:FireServer()
    end
end)```
#

but its not done yet

#

create a remoteevent in replicatedstorage

#

name it consequenceremote

#

capitalized

#

so its

#

ConsequenceRemote

#

then put this in a server side script (normal script) in serverscriptservice

#

replicatedStorage.ConsequenceRemote.OnServerEvent:Connect(function(plr)
    plr:Kick('blah blah')
end)```
split tulip
cerulean steeple
#

yes

coarse furnaceBOT
#

studio** You are now Level 3! **studio

split tulip
#

ok

cerulean steeple
#

mee6 shut the f up

split tulip
#

i got a folder holding all the remote events

#

will it break if i put it in there?